//
//  YMCheckTopStepView.m
//  YMMedical
//
//  Created by y s on 2023/7/22.
//

#import "YMCheckTopStepView.h"

@interface YMCheckTopStepView ()

@property (nonatomic, strong) UIView *vStep1;
@property (nonatomic, strong) UILabel *lblStep1;

@property (nonatomic, strong) UIView *vStep2;
@property (nonatomic, strong) UIView *vLine2;
@property (nonatomic, strong) UILabel *lblStep2;

@property (nonatomic, strong) UIView *vStep3;
@property (nonatomic, strong) UIView *vLine3;
@property (nonatomic, strong) UILabel *lblStep3;

@property (nonatomic, strong) UIView *vStep4;
@property (nonatomic, strong) UIView *vLine4;
@property (nonatomic, strong) UILabel *lblStep4;

@property (nonatomic, strong) UIView *vStep5;
@property (nonatomic, strong) UIView *vLine5;
@property (nonatomic, strong) UILabel *lblStep5;


@end

@implementation YMCheckTopStepView

- (instancetype)init{
    self = [super init];
    if (self) {
        [self setUI];
    }
    return self;
}

#pragma mark -- UI
- (void)setUI{
    self.backgroundColor = STheme.D9;
    [self addSubview:self.vStep1];
    [self addSubview:self.lblStep1];
    [self addSubview:self.vStep2];
    [self addSubview:self.lblStep2];
    [self addSubview:self.vLine2];
    [self addSubview:self.vStep3];
    [self addSubview:self.lblStep3];
    [self addSubview:self.vLine3];
    [self addSubview:self.vStep4];
    [self addSubview:self.lblStep4];
    [self addSubview:self.vLine4];
    [self addSubview:self.vStep5];
    [self addSubview:self.lblStep5];
    [self addSubview:self.vLine5];

    [self.vStep1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo([SFitUtil fit:45]);
        make.top.mas_equalTo([SFitUtil fit:16]);
        make.size.mas_equalTo([SFitUtil fitSize:8 height:8]);
    }];
    [self.lblStep1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.vStep1.mas_bottom).offset([SFitUtil fit:8]);
        make.centerX.equalTo(self.vStep1);
    }];
    [self.vLine2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.vStep1.mas_right);
        make.centerY.equalTo(self.vStep1);
        make.height.mas_equalTo([SFitUtil fit:1]);
    }];
    [self.vStep2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.vLine2.mas_right);
        make.centerY.width.height.equalTo(self.vStep1);
        make.size.equalTo(self.vStep1);
    }];
    [self.lblStep2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.vStep2.mas_bottom).offset([SFitUtil fit:8]);
        make.centerX.equalTo(self.vStep2);
    }];
    [self.vLine3 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.vStep2.mas_right);
        make.centerY.equalTo(self.vStep1);
        make.size.equalTo(self.vLine2);
    }];
    [self.vStep3 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.vLine3.mas_right);
        make.centerY.width.height.equalTo(self.vStep1);
        make.size.equalTo(self.vStep1);
    }];
    [self.lblStep3 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.vStep3.mas_bottom).offset([SFitUtil fit:8]);
        make.centerX.equalTo(self.vStep3);
    }];
    [self.vLine4 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.vStep3.mas_right);
        make.centerY.equalTo(self.vStep1);
        make.size.equalTo(self.vLine2);
    }];
    [self.vStep4 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.vLine4.mas_right);
        make.centerY.width.height.equalTo(self.vStep1);
        make.size.equalTo(self.vStep1);
    }];
    [self.lblStep4 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.vStep4.mas_bottom).offset([SFitUtil fit:8]);
        make.centerX.equalTo(self.vStep4);
    }];
    [self.vLine5 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.vStep4.mas_right);
        make.centerY.equalTo(self.vStep1);
        make.size.equalTo(self.vLine2);
    }];
    [self.vStep5 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.vLine5.mas_right);
        make.centerY.width.height.equalTo(self.vStep1);
        make.size.equalTo(self.vStep1);
        make.right.mas_equalTo([SFitUtil fit:-45]);
    }];
    [self.lblStep5 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.vStep5.mas_bottom).offset([SFitUtil fit:8]);
        make.centerX.equalTo(self.vStep5);
    }];
    
}

- (void)setStep:(NSInteger)step{
    _step = step;
    
    self.vStep1.backgroundColor = STheme.D5;
    self.vStep1.layer.borderColor = STheme.D5.CGColor;
    self.lblStep1.textColor = STheme.D3;
    
    self.vStep2.backgroundColor = STheme.D5;
    self.vStep2.layer.borderColor = STheme.D5.CGColor;
    self.lblStep2.textColor = STheme.D3;
    self.vLine2.backgroundColor = STheme.D5;
    
    self.vStep3.backgroundColor = STheme.D5;
    self.vStep3.layer.borderColor = STheme.D5.CGColor;
    self.lblStep3.textColor = STheme.D3;
    self.vLine3.backgroundColor = STheme.D5;
    
    self.vStep4.backgroundColor = STheme.D5;
    self.vStep4.layer.borderColor = STheme.D5.CGColor;
    self.lblStep4.textColor = STheme.D3;
    self.vLine4.backgroundColor = STheme.D5;
    
    self.vStep5.backgroundColor = STheme.D5;
    self.vStep5.layer.borderColor = STheme.D5.CGColor;
    self.lblStep5.textColor = STheme.D3;
    self.vLine5.backgroundColor = STheme.D5;

    if (step > 0){
        self.vStep1.backgroundColor = [UIColor whiteColor];
        self.vStep1.layer.borderColor = STheme.D12.CGColor;
        self.lblStep1.textColor = STheme.D12;
    }
    if (step > 1){
        self.vStep1.backgroundColor = STheme.D12;
        self.vStep2.backgroundColor = [UIColor whiteColor];
        self.vStep2.layer.borderColor = STheme.D12.CGColor;
        self.lblStep2.textColor = STheme.D12;
        self.vLine2.backgroundColor = STheme.D12;
    }
    if (step > 2){
        self.vStep2.backgroundColor = STheme.D12;
        self.vStep3.backgroundColor = [UIColor whiteColor];
        self.vStep3.layer.borderColor = STheme.D12.CGColor;
        self.lblStep3.textColor = STheme.D12;
        self.vLine3.backgroundColor = STheme.D12;
    }
    if (step > 3){
        self.vStep3.backgroundColor = STheme.D12;
        self.vStep4.backgroundColor = [UIColor whiteColor];
        self.vStep4.layer.borderColor = STheme.D12.CGColor;
        self.lblStep4.textColor = STheme.D12;
        self.vLine4.backgroundColor = STheme.D12;
    }
    if (step > 4){
        self.vStep4.backgroundColor = STheme.D12;
        self.vStep5.backgroundColor = [UIColor whiteColor];
        self.vStep5.layer.borderColor = STheme.D12.CGColor;
        self.lblStep5.textColor = STheme.D12;
        self.vLine5.backgroundColor = STheme.D12;
    }
}

#pragma mark -- setter and getter
- (UIView *)vStep1{
    if (_vStep1 == nil){
        _vStep1 = [[UIView alloc] init];
        _vStep1.backgroundColor = [UIColor whiteColor];
        _vStep1.clipsToBounds = YES;
        _vStep1.layer.cornerRadius = [SFitUtil fit:8]*0.5;
        _vStep1.layer.borderWidth = [SFitUtil fit:1];
        _vStep1.layer.borderColor = STheme.D12.CGColor;
    }
    return _vStep1;
}
- (UILabel *)lblStep1{
    if (_lblStep1 == nil){
        _lblStep1 = [SThemeUtil label:KLanguage(@"first_step") color:STheme.H_D12 fontSize:13];
    }
    return _lblStep1;
}
- (UIView *)vStep2{
    if (_vStep2 == nil){
        _vStep2 = [[UIView alloc] init];
        _vStep2.backgroundColor = STheme.D5;
        _vStep2.clipsToBounds = YES;
        _vStep2.layer.cornerRadius = [SFitUtil fit:8]*0.5;
        _vStep2.layer.borderWidth = [SFitUtil fit:1];
        _vStep2.layer.borderColor = STheme.D5.CGColor;
    }
    return _vStep2;
}
- (UIView *)vLine2{
    if (_vLine2 == nil){
        _vLine2 = [[UIView alloc] init];
        _vLine2.backgroundColor = STheme.D5;
    }
    return _vLine2;
}
- (UILabel *)lblStep2{
    if (_lblStep2 == nil){
        _lblStep2 = [SThemeUtil label:KLanguage(@"two_step") color:STheme.H_D9 fontSize:13];
    }
    return _lblStep2;
}
- (UIView *)vStep3{
    if (_vStep3 == nil){
        _vStep3 = [[UIView alloc] init];
        _vStep3.backgroundColor = STheme.D5;
        _vStep3.clipsToBounds = YES;
        _vStep3.layer.cornerRadius = [SFitUtil fit:8]*0.5;
        _vStep3.layer.borderWidth = [SFitUtil fit:1];
        _vStep3.layer.borderColor = STheme.D5.CGColor;
    }
    return _vStep3;
}
- (UIView *)vLine3{
    if (_vLine3 == nil){
        _vLine3 = [[UIView alloc] init];
        _vLine3.backgroundColor = STheme.D5;
    }
    return _vLine3;
}
- (UILabel *)lblStep3{
    if (_lblStep3 == nil){
        _lblStep3 = [SThemeUtil label:KLanguage(@"three_step") color:STheme.H_D9 fontSize:13];
    }
    return _lblStep3;
}
- (UIView *)vStep4{
    if (_vStep4 == nil){
        _vStep4 = [[UIView alloc] init];
        _vStep4.backgroundColor = STheme.D5;
        _vStep4.clipsToBounds = YES;
        _vStep4.layer.cornerRadius = [SFitUtil fit:8]*0.5;
        _vStep4.layer.borderWidth = [SFitUtil fit:1];
        _vStep4.layer.borderColor = STheme.D5.CGColor;
    }
    return _vStep4;
}
- (UIView *)vLine4{
    if (_vLine4 == nil){
        _vLine4 = [[UIView alloc] init];
        _vLine4.backgroundColor = STheme.D5;
    }
    return _vLine4;
}
- (UILabel *)lblStep4{
    if (_lblStep4 == nil){
        _lblStep4 = [SThemeUtil label:KLanguage(@"four_step") color:STheme.H_D9 fontSize:13];
    }
    return _lblStep4;
}
- (UIView *)vStep5{
    if (_vStep5 == nil){
        _vStep5 = [[UIView alloc] init];
        _vStep5.backgroundColor = STheme.D5;
        _vStep5.clipsToBounds = YES;
        _vStep5.layer.cornerRadius = [SFitUtil fit:8]*0.5;
        _vStep5.layer.borderWidth = [SFitUtil fit:1];
        _vStep5.layer.borderColor = STheme.D5.CGColor;
    }
    return _vStep5;
}
- (UIView *)vLine5{
    if (_vLine5 == nil){
        _vLine5 = [[UIView alloc] init];
        _vLine5.backgroundColor = STheme.D5;
    }
    return _vLine5;
}
- (UILabel *)lblStep5{
    if (_lblStep5 == nil){
        _lblStep5 = [SThemeUtil label:KLanguage(@"five_step") color:STheme.H_D9 fontSize:13];
    }
    return _lblStep5;
}

@end
